const express = require('express')
const bodyParser = require('body-parser');

const app = express()
const port = 3000

app.use(bodyParser.json());

app.get('/', (req, res) => {
    // res.send('Hello World!')
    res.json(req.query)
    // res.redirect('/ping')

})

app.get('/ping/:uid/:uuid', (req, res) => {
    console.log(req.params)
    let uid = req.params.uid
    console.log(uid)
    res.json(req.params)
})

//在根路由 (/) 上（应用程序的主页）对 POST 请求进行响应：
app.post('/', function (req, res) {
    console.log(req.body)
    res.json(req.body);

});

//  对 /user 路由的 PUT 请求进行响应：
app.put('/user', function (req, res) {
    res.send('Got a PUT request at /user');
});

//  对 /user 路由的 DELETE 请求进行响应：
app.delete('/user', function (req, res) {
    res.send('Got a DELETE request at /user');
});

app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`)
})